- if @findings
  - if @autoadd
    .d-flex.justify-content-between.flex-wrap.flex-md-nowrap.align-items-center.pt-3.pb-2.mb-3.border-bottom
      %h1.h2 Auto Add Findings
    %h2.h5 The following findings were automatically selected to be added to your report.
  - else
    .d-flex.justify-content-between.flex-wrap.flex-md-nowrap.align-items-center.pt-3.pb-2.mb-3.border-bottom
      %h1.h2 Templated Findings
    %h2.h5 Add findings from the template database to your report.

  .form-group.has-search.row.mt-5
    .col-6
      %span.fa.fa-search.form-control-feedback
      %input#search.form-control{ :type => "text", :placeholder => "Finding Name Search" }
  %style#search_style
  
  %form{ :method => "post", :action => "/report/#{@report.id}/findings_add" }
    .table.table-sm
      %table{ :style => "width: 90%" }
        %tbody
        - settings.finding_types.each do |type|
          %tr
            %td{ :colspan => "2" }
              %b.pointer{ "data-toggle" => "collapse", "data-target" => "#findings_list_#{type.gsub(' ','_')}" }
                #{type}
                %i.fas.fa-list
              -if @findings.any?{|finding| finding.type === type}
                .findings_list{ :id => "findings_list_#{type.gsub(' ','_')}", :class => "collapse in show" }
                  - if @findings.size > 0
                    .table.table-hover.table-sm
                      %table{ :style => "width: 100%" }
                        - @findings.each do |finding|
                          - if finding.type == type
                            - if @languages and @languages.size > 1
                              - next unless (finding.language == @report.language) or (@report.language == "English" and finding.language == nil)
                            %tr
                              %td.searchable{ :style => "width: 80%", :"data-index" => "#{finding.title.downcase}" }
                                - if @autoadd
                                  - if @autoadd_findings.include?(finding.id.to_s) and not @dup_findings.include?(finding.id)
                                    %input{ :id => "finding_#{finding.id}", :type => "checkbox", :name => "finding[]", :value => "#{finding.id}", :checked => "" }
                                  - else
                                    %input{ :id => "finding_#{finding.id}", :type => "checkbox", :name => "finding[]", :value => "#{finding.id}" }
                                - else
                                  %input{ :id => "finding_#{finding.id}", :type => "checkbox", :name => "finding[]", :value => "#{finding.id}" }
                                %label.control-label{ :for => "finding_#{finding.id}" }
                                  #{finding.title}
                                - if @dup_findings
                                  - if @dup_findings.include?(finding.id)
                                    .label.label-warning Duplicate
                                - if finding.overview
                                  %i.fas.fa-chevron-down.pointer{ "data-toggle" => "collapse", "data-target" => "#info_#{finding.id}" }
                                  .info.collapse.out{ :id => "info_#{finding.id}" }
                                    #{finding.overview.gsub("<paragraph>","<br />").gsub("</paragraph>","").gsub("<bullet>","&#x2022;").gsub("</bullet>","")}
                                  - if @autoadd_hosts
                                    - @autoadd_hosts.keys.each do |x|
                                      - if finding.id == x.to_i
                                        - @autoadd_hosts[x].each do |ip|
                                          .label.label-default #{ip}
                                        - iplist = @autoadd_hosts[x].join(",")
                                        %input{ :type => "hidden", :name => "finding#{finding.id.to_s}", :value => "#{iplist}" }
                              %td.searchable{ :style => "width: 20%", :"data-index" => "#{finding.title.downcase}" }
                                - if @master
                                  %a.btn.btn-sm.btn-warning{ :href => "/master/findings/#{finding.id}/edit" }
                                    %i.fas.fa-pencil-alt{ :title => "Edit" }
                                  %a.btn.btn-sm.btn-info{ :href => "/master/findings/#{finding.id}/preview" }
                                    %i.far.fa-play-circle{ :title => "Preview" }
                                - else
                                  %a.btn.btn-sm.btn-info{ :href => "/master/findings/#{finding.id}/preview" }
                                    %i.far.fa-play-circle{ :title => "Preview" }

    %input.btn.btn-primary{ :type => "submit", :value => "Add" }
    %a.btn.btn-secondary{ :href => "/report/#{@report.id}/findings" }
      Cancel
- else
  No Findings Available
